{include file="public/layout" /}
<body>
<link rel="stylesheet" href="__SKIN__/css/page.css" media="all">
<div class="layui-fluid" id="LAY-component-layer-list">
    <div class="layui-card">
        <div class="head-oper">
            <div class="fl">
                {eq name="'Users@add'|is_check_access" value="1"}
                <a data-url="{:url('Users/add',['back'=>'saleman_list'])}" data-type="Users_add" class="layui-btn mt5 ">新增经纪人</a>
                {/eq}
            </div>
            <div class="fr">
                <form action="{:url('Users/index')}" method="get" onsubmit="layer_loading();">
                    <div class="fl mt5" >
                        <div class="layui-input-inline w240">
                            {$searchform.hidden|default=''}
                            <input type="text" name="keywords" id="keywords" value="{$Request.param.keywords}" placeholder="搜索相关数据…" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-input-inline w50 mt5">
                        <button class="layui-btn input-btn-search" type="submit"><i class="layui-icon layui-icon-search"></i></button>
                    </div>
                </form>
            </div>
        </div>
        <div class="layui-card-body">
            <div class="layui-form layui-border-box layui-table-view house-table" lay-id="admin-arctype" >
                <div class="layui-table-box">
                    <div class="layui-table-body " >
                        <table cellspacing="0" cellpadding="0" border="0" class="layui-table layui-form" style="width: 100%" lay-skin="line">
                            <thead >
                            <tr>
                                <th class="w40 tc">
                                    <div class="layui-table-cell w40 tc laytable-cell-checkbox">
                                        <input type="checkbox" lay-filter="checkAll" class="checkAll" lay-skin="primary">
                                        <div class="layui-unselect layui-form-checkbox" lay-skin="primary"> <i class="layui-icon layui-icon-ok"></i></div>
                                    </div>
                                </th>
                                <th class="w60 tc">
                                    <div class="layui-table-cell w60 tc" ><span>ID</span></div>
                                </th>
                                <th>
                                    <div class="layui-table-cell wauto"><span>会员级别</span></div>
                                </th>
                                <th class="w150 tc">
                                    <div class="layui-table-cell w150 tc"><span>用户名</span></div>
                                </th>
                                <th class="w150 tc">
                                    <div class="layui-table-cell w150 tc"><span>真实姓名</span></div>
                                </th>
                                <th class="w150 tc">
                                    <div class="layui-table-cell w150 tc"><span>手机号</span></div>
                                </th>
                                <th class="w200 tc">
                                    <div class="layui-table-cell w200 tc"><span>注册时间</span></div>
                                </th>
                                <th class="w100 tc">
                                    <div class="layui-table-cell w100 tc"><span>内部人员</span></div>
                                </th>
                                <th class="w100 tc">
                                    <div class="layui-table-cell w100 tc"><span>启用</span></div>
                                </th>
                                <th class="w150 tc">
                                    <div class="layui-table-cell w150 tc"><span>操作</span></div>
                                </th>
                            </tr>
                            </thead>
                            <tbody>
                            {empty name="list"}
                            <tr>
                                <td colspan="8" class="no-data tc">
                                    没有符合条件的数据
                                </td>
                            </tr>
                            {else/}
                            {foreach name="list" item="vo" key="k" }
                            <tr>
                                <td>
                                    <div class="layui-table-cell w40 tc laytable-cell-checkbox">
                                        <input type="checkbox" name="ids[]" lay-filter="ids" lay-skin="primary" value="{$vo.id}">
                                    </div>
                                </td>
                                <td><div class="layui-table-cell w60 tc"> {$vo.id} </div></td>
                                <td>
                                    <div class="layui-table-cell wauto" title="{$vo.level_name}">
                                        {$vo.level_name}
                                    </div>
                                </td>
                                <td>
                                    <div class="layui-table-cell w150 tc">
                                        {$vo.username}
                                    </div>
                                </td>
                                <td>
                                    <div class="layui-table-cell w150 tc">
                                        {$vo.true_name}
                                    </div>
                                </td>
                                <td>
                                    <div class="layui-table-cell w150 tc">
                                        {$vo.mobile}
                                    </div>
                                </td>
                                <td>
                                    <div class="layui-table-cell w200 tc">
                                        {$vo.add_time|MyDate="Y-m-d H:i:s",###}
                                    </div>
                                </td>
                                <td>
                                    <div class="layui-table-cell w100 tc">
                                        <input type="checkbox" lay-skin="switch" lay-filter="is_saleman" data-id="{$vo.id}" {eq name="$vo['is_saleman']" value='1'}value="off" checked{else /}value="on"{/eq} lay-text="是|否">
                                    </div>
                                </td>
                                <td>
                                    <div class="layui-table-cell w100 tc">
                                        <input type="checkbox" lay-skin="switch" lay-filter="is_activation" data-id="{$vo.id}" {eq name="$vo['is_activation']" value='1'}value="off" checked{else /}value="on"{/eq} lay-text="是|否">
                                    </div>
                                </td>
                                <td>
                                    <div class="layui-table-cell w150 tc right-oper">
                                        {eq name="'Users@edit'|is_check_access" value="1"}
                                        <a class="layui-btn btn-edit customvar_edit" data-url="{:url('Users/edit',array('id'=>$vo['id'],'back'=>'saleman_list'))}" data-type="Users_edit">编辑</a>
                                        {/eq}
                                        {eq name="'Users@del'|is_check_access" value="1"}
                                        <a href="javascript:void(0);" class="layui-btn btn-primary" data-url="{:url('Users/del')}" data-id="{$vo.id}" onClick="delfun(this);">删除</a>
                                        {/eq}
                                    </div>
                                </td>
                            </tr>
                            {/foreach}
                            {/empty}
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="layui-table-page footer-oper">
                    <input type="checkbox" lay-filter="checkAll" class="checkAll" lay-skin="primary" >
                    {eq name="'Users@del'|is_check_access" value="1"}
                    <a class="layui-btn layui-btn-primary" data-type="batch_del" data-url="{:url('Users/del')}" data-deltype="pseudo" style="line-height: 34px;">
                        批量删除
                    </a>
                    {/eq}
                </div>
                <!--分页-->
            </div>
            {$pageStr}
        </div>
    </div>
</div>
<script>
    layui.config({
        base: '__SKIN__/' //静态资源所在路径
        ,version: '{$version}'
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form'], function(){
        var $ = layui.$
            ,form = layui.form;

        form.on('switch(is_saleman)', function(data){
            changeTableVal('users','id',$(this).data('id'),'is_saleman',this);
            return false;
        });
        form.on('switch(is_activation)', function(data){
            changeTableVal('users','id',$(this).data('id'),'is_activation',this);
            return false;
        });

        // 监听复选框全选
        form.on('checkbox(checkAll)', function(data){
            if (data.elem.checked) {
                $('.checkAll').attr('checked', true);
                $('input[name*=ids]').attr('checked', true);
            } else {
                $('.checkAll').attr('checked', false);
                $('input[name*=ids]').attr('checked', false);
            }
            form.render('checkbox');
        });

        // 监听每行复选框
        form.on('checkbox(ids)', function(data){
            if (data.elem.checked && $('input[name*=ids]:checked').length == $('input[name*=ids]').length) {
                $('.checkAll').attr('checked', true);
            } else {
                $('.checkAll').attr('checked', false);
            }
            form.render('checkbox');
        });

        /* 触发事件 */
        var active = {
            // 新增
            Users_add: function(){
                var iframes = layer.open({
                    type: 2,
                    title: '新增会员',
                    fixed: true, //不固定
                    shadeClose: false,
                    shade: 0.3,
                    content: $(this).data('url')
                });
                layer.full(iframes);
            }
            // 编辑
            ,Users_edit: function(){
                var iframes = layer.open({
                    type: 2,
                    title: '编辑会员',
                    fixed: true, //不固定
                    shadeClose: false,
                    shade: 0.3,
                    content: $(this).data('url')
                });
                layer.full(iframes);
            }
            // 批量删除
            ,batch_del: function(){
                batch_del(this,'ids');
            }
        };

        $('#LAY-component-layer-list .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] && active[type].call(this);
        });

    });

</script>
{include file="public/footer" /}